Don't fail!() when rustdoc fails to run
authorAlex Crichton <alex@alexcrichton.com>
Sun, 31 Aug 2014 06:19:38 +0000 (23:19 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 3 Sep 2014 00:24:53 +0000 (17:24 -0700)
The return value of `err.output()` will be `None` if the rustdoc executable
failed to spawn, in which case we can give a more graceful error message.

Closes #481

src/cargo/ops/cargo_rustc/mod.rs

index 6b725426738801e9cbf9f322bb2ced3fadaedf2d..e4fe8de044fc0c572a4435dc317ec73c22c01270 100644 (file)
@@ -273,8 +273,15 @@ fn rustdoc(package: &Package, target: &Target, cx: &mut Context) -> Work {
             }))
         } else {
             try!(rustdoc.exec_with_output().and(Ok(())).map_err(|err| {
-                caused_human(format!("Could not document `{}`.\n{}",
-                                     name, err.output().unwrap()), err)
+                match err.output() {
+                    Some(output) => {
+                        caused_human(format!("Could not document `{}`.\n{}",
+                                             name, output), err)
+                    }
+                    None => {
+                        caused_human("Failed to run rustdoc", err)
+                    }
+                }
             }))
         }
         Ok(())